#ifndef NXBOT_H
#define NXBOT_H
/**
 * @defgroup nxbot_low_level LOW Layer
 * @brief This Layer acts as a HAL (Hardware abstraction Layer) for interfacing the devices connected to the microcontroller system.
 *
 * @defgroup nxbot_high_level HIGH Layer
 * @brief This Layer presents common interfaces for control. It takes extensively use of structures for sharing information.
 *
 * @defgroup nxbot_task_level TASK Layer
 * @brief This Layer presents the tasks implemented RTOS.
 *
 * \mainpage NXBot Firmware
 *
 * This documentation describes the firmware used in the NXBOT Robot of the Universidad del Valle in Cali, Colombia. 
 * \image html images/nxbot/nxbot_frente.png
 * The main objectives is to introduce the developer to all the functions used to control the low-level hardware of the robot; that means
 * the actuators and sensors. NXBOT is a robot with differential drive, that means it has two motors and a ... rueda loca for its steering.
 * It uses an IR sensor belt, composed by 6 IRs, located at -90°, -45°, -10°, 10°, 45°, 90° of the robot. Some versions include ultrasound sensors,
 * and the configuration of them depends mainly on the user. There is also a bumper belt, composed by 4 bumpers, located at 45°, -45°,135°, -135°.
 * Other sensors include the battery state and a buzzer. The following list describes the hardware used in NXBot.
 * <ul>
 * <li>Sensors
 * <ol>
 * <li>IR
 * <li>Sonar
 * <li>Bumper
 * <li>Encoders 
 * <li>Battery
 * </ol>
 * <li>Actuators
 * <ol>
 * <li>Motors
 * <li>Buzzer
 * </ol>
 * </ul>
 *
 * Poner quue la estructura esta dividida en capas, donde la primera  capa actua como HAL y es llamada @ref nxbot_low_level, la segunda genera
 * estructuras más genéricas, y la tercera 
 * \author Alejandro Pustowka, Jonathan Hernandez
 * \date March-2010
 */


/*
* \brief
*/
//Cuantities used for NXBOT
#define NXBOT_ENCODER_RES (575.959/1000000.0)
#define NXBOT_WHEEL_DISTANCE 0.15//0.1575

#define NXBOT_BATT_ALARM 550

//Task frequencies. Modify this as you wish
#define MOTOR_INTERVAL_HZ		40 //executed at 40 Hz
#define COMM_INTERVAL_HZ		300 //executed at 300 Hz
#define SENSOR_INTERVAL_HZ	150 // executed at 150 Hz
#define SONAR_INTERVAL_HZ	12 // executed at 12 Hz

//Tasks intervals in TICK units (DO NOT CHANGE!! MODIFY INSTEAD THE ABOVE FREQUENCIES IN HZ!!)
#define MOTOR_INTERVAL		F_RTOS/MOTOR_INTERVAL_HZ
#define COMM_INTERVAL			F_RTOS/COMM_INTERVAL_HZ
#define SENSOR_INTERVAL		F_RTOS/SENSOR_INTERVAL_HZ
#define SONAR_INTERVAL		F_RTOS/SONAR_INTERVAL_HZ
#define SEC1_INTERVAL			F_RTOS
#define SEC3_INTERVAL			F_RTOS*3
#define SEC5_INTERVAL			F_RTOS*5



#include <avr/interrupt.h>

//Available Tasks
#include "commKTask.h"
#include "motorsTask.h"
#include "sensorsTask.h"
//#include "PIControlTask.h"
#include "soundTask.h"
#include "sonarTask.h"

//high level routines
#include "commK.h"
#include "motors.h"
#include "sensors.h"
#include "sound.h"

//low level routines (TODO: QUITAR ESTO)
#include "uart.h"

//#include "buzzer.h"

//global parameters
#include "structures.h"

//jingles for nxbot
Jingle J_CONN;
Jingle J_DISCONN;
Jingle J_BATT;


//function prototypes
void nxbot_init(void);

#endif
